printf "Don't execute this script directly.\n"
exit

# 来源：https://www.vultr.com/docs/using-your-ssh-key-to-login-to-non-root-users/?_gl=1*qqyw02*_ga*OTQxMjM5MzAwLjE2NjEyMTY4NDY.*_ga_K6536FHN4D*MTY2MzQwNDY3Ni43LjEuMTY2MzQwNTAwNi4wLjAuMA..

# 以下假定目标用户叫example_user
# 以下假定目标服务器叫example_host
# 以下假定下载到本地的私钥文件名为example_rsa

# 以root身份在服务器上登录
# SSH to the instance as root.

# Create an SSH key for example_user.
sudo -u example_user ssh-keygen

# Save the private key to your computer.
# (The following command should be executed on the local machine.)
scp root@example_host:~example_user/.ssh/id_rsa ~/.ssh/example_rsa

# Delete the private key from your instance.
rm ~example_user/.ssh/id_rsa

# Rename the public key to "authorized_keys".
mv ~example_user/.ssh/id_rsa.pub ~example_user/.ssh/authorized_keys

# To log in, use the following command:
# (The following command should be executed on the local machine.)
ssh -i ~/.ssh/example_rsa example_user@example_host

